home *** CD-ROM | disk | FTP | other *** search
- /*************************************************************************************
- #
- # aevt.c
- #
- # Apple events handler.
- #
- # Author(s): Michael Marinkovich
- # Apple Developer Technical Support
- # marink@apple.com
- #
- # Modification History:
- #
- # 4/3/96 MWM Initial coding
- #
- # Copyright © 1992-96 Apple Computer, Inc., All Rights Reserved
- #
- #
- # You may incorporate this sample code into your applications without
- # restriction, though the sample code has been provided "AS IS" and the
- # responsibility for its operation is 100% yours. However, what you are
- # not permitted to do is to redistribute the source as "DSC Sample Code"
- # after having made changes. If you're going to re-distribute the source,
- # we require that you make it clear in the source that the code was
- # descended from Apple Sample Code, but that you've made changes.
- #
- *************************************************************************************/
-
- #include <AppleEvents.h>
- #include <Windows.h>
-
- #include "App.h"
- #include "Proto.h"
-
-
- //----------------------------------------------------------------------
- // Globals
- //----------------------------------------------------------------------
-
- extern Boolean gDone;
-
-
- //----------------------------------------------------------------------
- //
- // AEInit - initialize all the core apple events
- //
- //
- //----------------------------------------------------------------------
-
- OSErr AEInit(void)
- {
- OSErr err = noErr;
-
- // install auto Open App
- err = AEInstallEventHandler(kCoreEventClass, kAEOpenApplication,
- NewAEEventHandlerProc(DoAEOpenApp), 0L, false );
-
- if (err == noErr) // install auto Quit App
- err = AEInstallEventHandler(kCoreEventClass, kAEQuitApplication,
- NewAEEventHandlerProc(DoAEQuitApp), 0L, false );
-
- if (err == noErr) // install auto Open Document
- err = AEInstallEventHandler(kCoreEventClass,kAEOpenDocuments,
- NewAEEventHandlerProc(DoAEOpenDoc),0L,false);
-
- if (err == noErr) // install auto Print Document
- err = AEInstallEventHandler(kCoreEventClass,kAEPrintDocuments,
- NewAEEventHandlerProc(DoAEPrintDoc),0L,false);
-
-
- return err;
-
- }
-
-
- //----------------------------------------------------------------------
- //
- // DoAEOpenApp - called by the Finder at launch time
- //
- //
- //----------------------------------------------------------------------
-
- pascal OSErr DoAEOpenApp(AppleEvent *event,AppleEvent reply,long refCon)
- {
- #pragma unused( event, reply, refCon )
-
-
- return noErr;
-
- }
-
-
- //----------------------------------------------------------------------
- //
- // DoAEQuitApp - called when the Finder asks app to quit
- //
- //
- //----------------------------------------------------------------------
-
- pascal OSErr DoAEQuitApp(AppleEvent *event,AppleEvent reply,long refCon)
- {
- #pragma unused( event, reply, refCon )
-
- // set the global quit flag
- gDone = true;
-
- return noErr;
-
- }
-
-
- //----------------------------------------------------------------------
- //
- // DoAEOpenDoc - called when the Finder asks app to open a document
- //
- //
- //----------------------------------------------------------------------
-
- pascal OSErr DoAEOpenDoc(AppleEvent *event,AppleEvent reply,long refCon)
- {
- #pragma unused( reply, refCon )
-
-
- return noErr;
-
- }
-
-
- //----------------------------------------------------------------------
- //
- // DoAEPrintDoc - called when the Finder asks app to print a document
- //
- //
- //----------------------------------------------------------------------
-
- pascal OSErr DoAEPrintDoc(AppleEvent *event,AppleEvent reply,long refCon)
- {
- #pragma unused( reply, refCon )
-
-
- return noErr;
-
- }
-
-
- //----------------------------------------------------------------------
- //
- // GotAEParams - make sure we got proper AE params for an Open
- // Document from the Finder
- //
- //----------------------------------------------------------------------
-
- OSErr GotAEParams(AppleEvent *appleEvent)
- {
- OSErr err;
- DescType type;
- Size size;
-
- err = AEGetAttributePtr(appleEvent,keyMissedKeywordAttr,
- typeWildCard,&type,nil,0,&size);
-
- if (err == errAEDescNotFound)
- return(noErr);
-
- else
- if (err == noErr)
- return(errAEEventNotHandled);
-
- return err;
-
- }
-